import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from "path";
const pathResolve = (dir: string): any => {  
  return resolve(__dirname, ".", dir)          
}

const alias: Record<string, string> = {
  '@': pathResolve("src")
}
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
  ],
  
  resolve: {
    alias
  },
  //配置axios
  optimizeDeps: {
    include: ['axios'],
  },
  build: {
    target: 'modules',
    outDir: 'dist',
    assetsDir: 'assets',
    minify: 'terser' // 混淆器
  },
  // 代理配置
  server: {
    // cors: true,
    // open: true,
    proxy: {
      '/api': {
        target: 'http://8.134.36.21',   //代理接口   http://8.134.36.21:8080/
        changeOrigin: true,   // 跨域
        // rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
  }
})
